/**
 * API配置文件
 * 统一管理API相关的配置信息
 */

// API基础配置
export const API_CONFIG = {
  // 基础URL
  BASE_URL: 'http://192.168.31.87:8081',
  
  // 请求超时时间（毫秒）
  TIMEOUT: 10000,
  
  // 默认请求头
  DEFAULT_HEADERS: {
    'Content-Type': 'application/json'
  },
  
  // 分页配置
  PAGINATION: {
    DEFAULT_CURRENT: 1,
    DEFAULT_SIZE: 10,
    MAX_SIZE: 100
  }
}

// 环境配置
export const ENV_CONFIG = {
  // 开发环境
  development: {
    BASE_URL: 'http://192.168.31.87:8081',
    DEBUG: true
  },
  
  // 测试环境
  test: {
    BASE_URL: 'http://test-api.fudaojun.com',
    DEBUG: true
  },
  
  // 生产环境
  production: {
    BASE_URL: 'https://api.fudaojun.com',
    DEBUG: false
  }
}

// 获取当前环境配置
export const getCurrentEnvConfig = () => {
  // 可以根据实际情况判断当前环境
  const env = process.env.NODE_ENV || 'development'
  return ENV_CONFIG[env] || ENV_CONFIG.development
}

// API路径常量
export const API_PATHS = {
  // 订单相关
  ORDER: {
    TEACHER_DETAIL: '/teach/api/order/getTeacherOrderDetail',
    STUDENT_DETAIL: '/teach/api/order/studentOrderDetail',
    STUDENT_LIST: '/teach/api/order/studentOrderList',
    TEACHER_LIST: '/teach/api/order/teacherOrderList'
  },
  
  // 老师相关
  TEACHER: {
    DETAIL: '/teach/api/teacher/detail',
    EDIT: '/teach/api/teacher/edit',
    LIST: '/teach/api/teacher/page',
    VERIFY: '/teach/api/teacher/verify',
    VERIFY_INFO: '/teach/api/teacher/verifyInfo'
  },
  
  // 投递相关
  DELIVERY: {
    ADD: '/teach/api/deliveryRecord/add'
  },

  // 需求相关
  REQUIREMENT: {
    ADD: '/teach/api/requirement/add',
    EDIT: '/teach/api/requirement/edit',
    GET: '/teach/api/requirement/get',
    PAGE: '/teach/api/requirement/page'
  }
}

// 响应状态码
export const RESPONSE_CODE = {
  SUCCESS: '1000',
  PARAM_ERROR: '400',
  NOT_FOUND: '404',
  METHOD_ERROR: '405',
  SERVER_ERROR: '500',
  SYSTEM_ERROR: '5000'
}

// 错误消息映射
export const ERROR_MESSAGES = {
  [RESPONSE_CODE.PARAM_ERROR]: '参数错误',
  [RESPONSE_CODE.NOT_FOUND]: '请求路径不存在',
  [RESPONSE_CODE.METHOD_ERROR]: '请求方式不支持',
  [RESPONSE_CODE.SERVER_ERROR]: '服务器错误',
  [RESPONSE_CODE.SYSTEM_ERROR]: '系统异常',
  'NETWORK_ERROR': '网络连接失败',
  'TIMEOUT_ERROR': '请求超时',
  'UNKNOWN_ERROR': '未知错误'
}
